package com.pangu.web.form;

import java.util.HashMap;
import java.util.Map;

public abstract class BaseForm {

	protected Map<String, String> errorMsgs;
	
	public Map<String, String> getErrorMsgs() {
		return errorMsgs;
	}
	
	public void addErrorMsg(String key, String message) {
		if (errorMsgs == null)
			errorMsgs = new HashMap<String, String>();
		
		errorMsgs.put(key, message);
	}
	
	public String getErrorMsg(String key) {
		return errorMsgs == null ? "" : errorMsgs.get(key);
	}
	
	public boolean isValid() {
		return errorMsgs == null || errorMsgs.size() == 0;
	}
	
	public abstract boolean validate();
}
